﻿using LJX.SmartPark.Common.ResponseOutput;
using LJX.SmartPark.Domain.SafeManage.Record;
using LJX.SmartPark.Domain.SafeManage.Train;
using LJX.SmartPark.Service.SafeManage;
using LJX.SmartPark.Service.SafeManage.Record;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using static LJX.SmartPark.Service.SafeManage.Record.RecordServeice;
using static LJX.SmartPark.Service.SafeManage.TrainServeice;

namespace LJX.SmartPark.WebApi.Controllers.SafeManage
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class RecordController : ControllerBase
    {
        private readonly IRecordServeice _recordServeice;

        public RecordController(IRecordServeice recordServeice)
        {
            _recordServeice = recordServeice;
        }

        /// <summary>
        /// 添加
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [HttpPost]
        public Task<Response<bool>> PostAddRecord(Record input)
        {
            var result = _recordServeice.PostAddRecordAsync(input);
            return result;
        }

        /// <summary>
        /// 删除
        /// </summary>
        /// <param name="input"></param>
        [HttpDelete]
        public Task<Response<bool>> DeleteRecord(Record input)
        {
            var result = _recordServeice.DeleteRecordAsync(input);
            return result;
        }

        /// <summary>
        /// 修改
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [HttpPut]
        public Task<Response<bool>> PutUpdateRecord(Record input)
        {
            var result = _recordServeice.PutUpdRecordAsync(input);

            return result;

        }

        /// <summary>
        /// 获取总条数
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        public int GetCount()
        {
            return _recordServeice.GetCount();
        }

        /// <summary>
        /// 显示
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        public Response<List<Record>> GetRecordAsync(FyRecord fyRecord)
        {
            var result = _recordServeice.GetRecordAsync(fyRecord);
            return result.Result;
        }

        /// <summary>
        /// 查询
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [HttpPost]
        public Response<Record> GetRecordById(Record input)
        {
            var result = _recordServeice.GetRecordById(input);
            return result;
        }
    }
}
